<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['ischecklogin']=cfc('core')->checklogin('','',true);
$_SESSION['uniacid']=$_SESSION['uniacid'];
if($_RQ['op']=='main'){
	$paycode=$_RQ['paycode'];
	$myfee=pdo_get('jy_shopmerch_myfee',array('paycode'=>$paycode,'uniacid'=>$_SESSION['uniacid']));
	if(empty($myfee)){
		exi('核销码错误,无法核销','error');   
	}
	if($myfee['paycodetime']+300<time()){
		//exi('核销码已失效（5分钟有效期）,请让客户刷新核销码！','error');   
	}
	$merch=model('jy_merch/verify')->checkuser($_SESSION['uid'],0,'',true);
	if($myfee['cityid']){
		$city=pdo_get('jy_shopmerch_city',array('id'=>$myfee['cityid'],'uniacid'=>$_SESSION['uniacid']));
		if(stripos($merch['pcd'], $city['title']) !== false){
		}else{
			exi('该用户不属于你商户旗下的城市站，无法消费！','error');   
		}
	}
	$return['post']=array(
		'myfeeid'=>$myfee['id'],
		'merchid'=>$merch['id'],
	);
	$return['myfee']=$myfee;
	$return['city']=$city;
	$return['merch']=$merch;
	$return['pcd']=$_SESSION['pcd'];
	$return['member']=cfc('core')->member_show($_SESSION['uid']);
	set_html('title','核销消费金');
    exi($return);
}

if($_RQ['op']=='post'){
	$post=get_postdata();
	$myfeeid=intval($post['myfeeid']);
	$merchid=intval($post['merchid']);
	if($merchid){
		$this->model('red')->hexiao($post);
		exi('核销成功！','','jy_merch/manage.index/');
	}else{
		exi('核销失败！','error');
	}
}